
package functionalEnrichment.semanticSimilarity.semanticSimilarityCalculator.program;

import functionalEnrichment.semanticSimilarity.semanticSimilarityCalculator.program.geneSetAnalysis.GeneSetAnalysisProgram;
import functionalEnrichment.semanticSimilarity.semanticSimilarityCalculator.program.similaritiesProgram.SimilaritiesProgram;

/**
 * Constants that hold the types of program that are run in the application.
 * @author Jamie MacPherson
 */
public enum ProgramType {


    GENE_SET_ANALYSIS("geneSetAnalysis"),
    CALCULATE_SIMILARITIES("similarities");
    
    private final String tag;

    /**
     * @param tag a string tag of one word that is attributed to the program.
     */
    private ProgramType(String tag) {
        this.tag = tag;
    }

    public static ProgramType getProgramFromTag(String tag) {
        for (ProgramType programType : ProgramType.values()) {
            if (programType.getTag().equals(tag)) {
                return programType;
            }
        }
        return null;
    }

   /**
    * get the tag for the program.
    * @return the tag.
    */

    public String getTag() {
        return tag;
    }

    /**
     * @return a set of Arguments that are the minimum requirement for the given program to run.
     */

    public Argument[] getRequiredArguments(){
        switch (this) {
            case GENE_SET_ANALYSIS: {
                Argument[] arguments = {Argument.SIMILARITIESFILE, Argument.RESULTSFILE, Argument.SUBJECTGENESFILE};
                return arguments;
            }

            case CALCULATE_SIMILARITIES: {
                Argument[] arguments = {Argument.SIMILARITIESFILE, Argument.GOAFILE, Argument.OBOFILE, Argument.ONTOLOGY};
                return arguments;
            }
            default: return null;

        }
    }

    /**
     *
     * @return a <code>Program</code> object corresponding to the given program type.
     */

    public Program getProgram() {

        Program program = null;
        switch (this) {
            case GENE_SET_ANALYSIS: {
                System.out.println("running gene set analysis program");
                program =  new GeneSetAnalysisProgram();
                break;
            }

            case CALCULATE_SIMILARITIES: {
                System.out.println("running similarities program");
                program =  new SimilaritiesProgram();
                break;
            }
        }
        program.setRequiredArguments(this.getRequiredArguments());
        return program;

    }
}
